#ifndef PROCESS_H_
#define PROCESS_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "evconnsvrd.h"
#include "proto_head.h"

/* process connev received data */
int32_t connev_process(struct connev_t* connev);

/*
*	client sync, send back encrypt key
*	return 0, process  success
*	return >0, pkg not full
*	return <0, process fail, destruct connection
*/
int32_t connev_proc_syn(struct connev_t* connev, struct conn_head_t* client_head);

/*
*	client ack, check encrypt key & notify to back-server
*	return 0, process  success
*	return >0, pkg not full
*	return <0, process fail, destruct connection
*/
int32_t connev_proc_ack(struct connev_t* connev, struct conn_head_t* client_head);

/*
*	client send pkg, foward to back-server
*	return 0, process  success
*	return >0, pkg not full
*	return <0, process fail, destruct connection
*/
int32_t connev_proc_pkg(struct connev_t* connev, struct conn_head_t* client_head);

/*
* pop one in waiting queue
*/
int32_t connev_proc_pop_queue();

/*
*	client heartbeat
*	return 0, process  success
*	return >0, pkg not full
*	return <0, process fail, destruct connection
*/
int32_t connev_proc_heartbeat(struct connev_t* connev, struct conn_head_t* client_head);

/* 
* process lsi read buffer 
* return 0: process success
* return >: no read data to process
*/
int32_t lsi_process();

/*
* back-server response connect
*/
int32_t lsi_proc_res(struct server_head_t* head);

/*
* back-server notify pkg
*/
int32_t lsi_proc_pkg(struct server_head_t* head, const char* buffer, int buffer_len);

/*
* back-server disconnect
*/
int32_t lsi_proc_disconn(struct server_head_t* head);


#ifdef __cplusplus
}
#endif

#endif // PROCESS_H_

